package com.qingxin.ui.bean;

import java.util.ArrayList;
import java.util.List;

import org.codehaus.jackson.map.annotate.JsonSerialize;


/**
 * 左侧风琴结构数据数据
 */
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class AccordionNode extends BaseNode {
	
	private String url;//type=tree时，获取树数据的地址
	private String expand;//type=tree时节点展开方式
	protected List<AccordionNode> children;
	
	public AccordionNode() {
	}
	
	
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getExpand() {
		return expand;
	}
	public void setExpand(String expand) {
		this.expand = expand;
	}
	public List<AccordionNode> getChildren() {
		return children;
	}
	public void setChildren(List<AccordionNode> children) {
		this.children = children;
	}
	public void addChild(AccordionNode node){
		if(children==null){
			children = new ArrayList<AccordionNode>();
		}
		children.add(node);
	}
	
	
	/**
	 * 深度复制
	 * @return
	 */
	public AccordionNode copy() {
		AccordionNode target = new AccordionNode();
		super.copyTo(target);
		target.setUrl(url);
		target.setExpand(expand);
		
		if(children!=null){
			List<AccordionNode> childrenNodeList = new ArrayList<AccordionNode>();
			for(AccordionNode node : children){
				childrenNodeList.add(node.copy());
			}
			target.setChildren(childrenNodeList);
		}
		
		return target;
	}
	
}
